<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    protected $table = 'articles';


    protected $appends = [
        'user_info' ,
        'image_info' ,

    ];

    public function getUserInfoAttribute()
    {
        return User::find($this->user_id);
    }


    public function getImageInfoAttribute()
    {
        $array = json_decode($this->image,true);
        if(empty($array)) return [];
        return File::whereIn("id",$array)->get();
    }
}
